package com.shouhuyun.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.shouhuyun.constant.MessageConstant;
import com.shouhuyun.entity.Result;
import com.shouhuyun.pojo.Setmeal;
import com.shouhuyun.service.SetmealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 套餐管理
 */

@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Reference  //Dubbo调用远程服务
    private SetmealService setmealService;

    //查询套餐列表
    @RequestMapping("/getAllSetmeal")
    public Result getAllSetmeal(){
        try {
            List<Setmeal> list = setmealService.findAll();

            return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS,list);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
    }

    //查询每一个套餐的详情 包括检查组检查项
    @RequestMapping("/findById_mobile")
    public Result findById_mobile(int id){
        try {
//            展示移动端套餐信息
            Setmeal setmeal = setmealService.findById_mobile(id);
            return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.QUERY_SETMEAL_FAIL);
        }


    }

}
